<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<shiro:hasPermission name="message:send:select">
<div class="content1">
	<div class="header">
		<h1 class="page-title">消息查询</h1>
		<ul class="breadcrumb">
			<li>消息管理</li>
			<li class="active">消息查询</li>
		</ul>
	</div>
		<div class="main-content">
			<div class="row">
				<div class="col-md-2">
					<div class="form-group">
						<div class="input-group">
							<div class="input-group-addon">手机号码</div>
							<input class="form-control" type="text" id="phoneNum">
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-md-2">
					<div class="form-group">
						<div class="input-group">
							<div class="input-group-addon">类型</div>
							<select class="form-control" id="messageType">
							  <option value="0">请选择类型</option>
							  <option value="1">个人信息</option>
							  <option value="2">通知信息</option>
							  <option value="3">活动消息</option>
							</select>
						</div>
					</div>
				</div>
				<div class="col-md-2">
					<div class="form-group">
						<div class="input-group">
							<div class="input-group-addon">读否</div>
							<select class="form-control" id="isRead">
							  <option value="0">请选择</option>
							  <option value="1">已读</option>
							  <option value="2">未读</option>
							</select>
						</div>
					</div>
				</div>
				<div class="col-md-2">
					<div class="form-group">
						<div class="input-group">
							<div class="input-group-addon">状态</div>
							<select class="form-control" id="state">
							  <option value="0">请选择</option>
							  <option value="1">有效</option>
							  <option value="2">用户删除</option>
							</select>
						</div>
					</div>
				</div>
				<div class="col-md-1">					
					<button type="button" class="btn btn-primary btn-small btn-block" id="query"><i class="glyphicon glyphicon-search"></i>查询</button>
				</div>
			</div>
			<table id="example" class="table"></table>
		</div>
	<script>
			//表格的初始化
			$(document).ready(function() {
				var table = $('#example').initTable({
					sAjaxSource:"message/initTable.htm",
					aoColumns: [
						{
						    "data": "phoneNum",
						    "sTitle":"手机号",
						    'sClass':"text-center"
						  },
			            { "data": "title","sTitle":"标题"},
			            { "data": "content","sTitle":"内容"},
			            { "data": "messageType","sTitle":"类型"},
			            { "data": "isRead","sTitle":"读否"},
			            { 
				              "data": "state",
				              "sTitle":"状态",
				              'sClass':"text-center",
				              "mRender": function(data, type, full) { 
				                	if(data == 1){
										return "<font>有效</font>";
									}else if(data == 2){
										return "<font>用戶刪除</font>";
									}else{
										return "<font>未知</font>";
									}
				                } 
				            },
			            { "data": "createTime","sTitle":"发送时间"},
			         ],
					 fnServerParams: function (aoData) {  //查询条件
		             	aoData.push(
		             			{ "name": "phoneNum", "value": $("#phoneNum").val() },
		             			{ "name": "title", "value": $("#title").val() },
		             			{ "name": "content", "value": $("#content").val() },
		             			{ "name": "messageType", "value": $("#messageType").val() },
		             			{ "name": "isRead", "value": $("#isRead").val() },
		             			{ "name": "state", "value": $("#state").val() });
		             },
		             aoColumnDefs : [
						{"aTargets" :4,"mRender" : function(data, type, row){
							if ("1" == row.messageType) {
							  return "个人信息" ;
							} else if ("2" == row.messageType) {
							  return "通知信息" ;
							} else if ("3" == row.messageType) {
							  return "活动消息" ;
							} 
							return "未知";
						  }
						},
						{"aTargets" :5,"mRender" : function(data, type, row){
							if ("1" == row.isRead) {
							  return "已读" ;
							}else if("2" == row.isRead){
								return "未读";
							}
						  }
						}
		             ]
				});
				
				 $('#query').click(function(){
					$('#example').dataTable().fnDraw();
				});
			
			});
			</script>
</div>
</shiro:hasPermission>